evtchn: allow many more evtchn objects to be allocated per domain
authorDavid Vrabel <david.vrabel@citrix.com>
Mon, 14 Oct 2013 08:19:21 +0000 (10:19 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 14 Oct 2013 08:19:21 +0000 (10:19 +0200)
commitea963e094a01cbbac203f0252c28808cfdc7f8ed
tree951acabd81e5cee8106a07e46d34b21b5c646b71
parent48974e6ce52ee21e08d0e621611371dc05624bbc
evtchn: allow many more evtchn objects to be allocated per domain

Expand the number of event channels that can be supported internally
by altering now struct evtchn's are allocated.

The objects are indexed using a two level scheme of groups and buckets
(instead of only buckets).  Each group is a page of bucket pointers.
Each bucket is a page-sized array of struct evtchn's.

The optimal number of evtchns per bucket is calculated at compile
time.

If XSM is not enabled, struct evtchn is 16 bytes and each bucket
contains 256, requiring only 1 group of 512 pointers for 2^17
(131,072) event channels.  With XSM enabled, struct evtchn is 24
bytes, each bucket contains 128 and 2 groups are required.

For the common case of a domain with only a few event channels,
instead of requiring an additional allocation for the group page, the
first bucket is indexed directly.

As a consequence of this, struct domain shrinks by at least 232 bytes
as 32 bucket pointers are replaced with 1 bucket pointer and (at most)
2 group pointers.

[ Based on a patch from Wei Liu with improvements from Malcolm
Crossley. ]

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
xen/common/event_channel.c
xen/include/xen/event.h
xen/include/xen/sched.h